package practice;

import java.util.Scanner;

public class _瞌睡_ {
    public static void main(String[] args) {
        _瞌睡_ c = new _瞌睡_();
        _瞌睡_.Solution s = c.getSolution();
        System.out.println(s.Main());
    }

    Solution getSolution() {
        return new Solution();
    }

    class Solution {
        public int Main() {
            Scanner sc = new Scanner(System.in);
            String line1 = sc.nextLine();
            String line2 = sc.nextLine();
            String line3 = sc.nextLine();
            String[] arr1 = line1.split(" ");
            int n = Integer.valueOf(arr1[0]);
            int m = Integer.valueOf(arr1[1]);
            String[] arr2 = line2.split(" ");
            String[] arr3 = line3.split(" ");
            int[] numarr2 = new int[n];
            for (int i = 0; i < n; i++) {
                numarr2[i] = Integer.valueOf(arr2[i]);
            }
            int[] numarr3 = new int[n];
            for (int i = 0; i < n; i++) {
                numarr3[i] = Integer.valueOf(arr3[i]);
            }
            int res = 0;
            for (int i = 0; i < n-m; i++) {
                int temp = countscore(numarr2,numarr3,i,m);
                if (temp > res) res = temp;
            }
//            return 1;
            System.out.println("res:"+ res);
            return res;
        }

        private int countscore(int[] arr1,int[] arr2, int index, int m) {
            int sum1 = 0, sum2 = 0, sum3 = 0;
            for (int i = 0; i < index; i++) {
                if (arr2[i] == 1)sum1 += arr1[i];
                else continue;
            }
            for (int i = index; i < index+m; i++) {
                sum2 += arr1[i];
            }
            for (int i = index + m; i < arr1.length; i++) {
                if (arr2[i] == 1)sum3 += arr1[i];
                else continue;
            }
            return  sum1+sum2+sum3;
        }
    }
}
